#include <stdio.h>
#include <sys/time.h>
#include <unistd.h>

int sqr(int num)
{
    sleep(1);
    return num * num;
}

int main(void)
{
    struct timeval start, end;
    gettimeofday(&start, NULL);
    int nums[5] = {1, 2, 3, 4, 5};
    int sqrs[5] = {0};
    for (int i = 0; i < 5; i++)
    {
        sqrs[i] = sqr(nums[i]);
    }
    gettimeofday(&end, NULL);
    printf("time: %ld\n", end.tv_sec - start.tv_sec);
    int sum = 0;
    for (int i = 0; i < 5; i++)
    {
        sum += sqrs[i];
    }
    printf("sum = %d\n", sum);
    return 0;
}